<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-blog-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">名称：</label>
				<div class="col-sm-8">
					<input id="blogname" name="blogname" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">标签：</label>
				<div class="col-sm-8">
					<input id="blogtype" name="blogtype" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">摘要：</label>
				<div class="col-sm-8">
					<input id="blogabstract" name="blogabstract" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">详情：</label>
				<div class="col-sm-8">
    				<textarea id="blogdetail" name="blogdetail"  class="form-control" placeholder="请输入文本"></textarea>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
				</div>
				<div class="col-sm-8">
					<button type="button" class="btn btn-default" onclick="submitHandler()">保存</button>
					
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/ckeditor/ckeditor.js}"></script>
	<script th:src="@{/ajax/libs/ckeditor/config.js}"></script>
    <script type="text/javascript">
    $(function() {
    	CKEDITOR.replace( 'blogdetail',{   
    		filebrowserUploadUrl : '/ckupload/uploadImg'
    		});	    	
    })
        
    
		var prefix = ctx + "system/blog"
		$("#form-blog-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	for ( instance in CKEDITOR.instances ){
	        		CKEDITOR.instances[instance].updateElement(); 
	        	}
	        	$.modal.loading("正在处理中，请稍后...");
            	var config = {
        	        url: prefix + "/add",
        	        type: "post",
        	        dataType: "json",
        	        data: $('#form-blog-add').serialize(),
        	        success: function(result) {
        	        	alert("保存成功！");
        	        	$.modal.closeLoading();
        	        }
        	    };
        	    $.ajax(config);
        	    
	        }
	    }
		
		
	</script>
</body>
</html>
